import { defineConfig } from "vite";
import path from "path";
import react from "@vitejs/plugin-react";
import VitePluginImp from "vite-plugin-imp";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    VitePluginImp({
      libList: [
        {
          libName: "antd",
          style(name) {
            // use less
            return `antd/es/${name}/style/index.js`;
          },
        }
      ],
    }),
  ],
  resolve: {
    alias: {
      // 这里的 @ 就是我们要为 src 配置的别名
      "@": path.resolve(__dirname, "./src"),
    },
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      }
    }
  },
  build: {
    // 指定打包输出路径 （相当于项目根目录）
    outDir: "build",
    sourcemap: true,
    commonjsOptions: {
      transformMixedEsModules: true,
    },
  },
});
